package com.example.clientwsphp;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;

import android.util.Log;

public class Controller {
	
	private static final String IP = "192.168.1.192";
	private static final String URL = "http://"+IP+"/WWW2/service/application/servicio_ejemplo/servicio_ejemploSOA.php";
	private static final String NAMESPACE = "http://"+IP+"/WWW2/service/application/servicio_ejemplo/servicio_ejemploSOA.php";

	public String galleta(String sabor) {

		String METHOD_NAME = "Galleta";
		String SOAP_ACTION = "http://"+IP+"/WWW2/service/application/servicio_ejemplo/servicio_ejemploSOA.php#Galleta";

		SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);

		// agregando parametro
		request.addProperty("sabor", sabor);

		// configurando envio
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		envelope.dotNet = true;
		envelope.setOutputSoapObject(request);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);

		try {
			androidHttpTransport.call(SOAP_ACTION, envelope);
			Log.i("devuelve: ", (String) envelope.getResponse());

			return (String) envelope.getResponse();

		} catch (Exception e) {
			e.printStackTrace();
			Log.i(METHOD_NAME, " error: " + e);
			return "Error de conexion con WS";
		}

}
	}
